import qs from 'qs'
export default {
    name: "Rapidupgrade",
    components: {},
    data() {
        return {
            cloudShow: '10G',
            cloudtitleupgrade: "云盘空间升级",
            deviceCountupgrade: "设备数量升级",
            bandwidthUpgrade: "带宽升级",
            lifetimeupgrade: "使用年限升级",
            List: [
                {
                    label: "10G",
                    name: "10G"
                },
                {
                    label: "20G",
                    name: "20G"
                },
                {
                    label: "50G",
                    name: "50G"
                },
                {
                    label: "100G",
                    name: "100G"
                },
                {
                    label: "200G",
                    name: "200G"
                },
                {
                    label: "500G",
                    name: "500G"
                },
                {
                    label: "1000G",
                    name: "1000G"
                }
            ],
            cloudShow1:"10个",
            List1: [
                {
                    label: "10个",
                    name: '10个'
                },
                {
                    label: "20个",
                    name: "20个"
                },
                {
                    label: "50个",
                    name: "50个"
                },
                {
                    label: "100个",
                    name: "100个"
                },
                {
                    label: "200个",
                    name: "200个"
                },
                {
                    label: "500个",
                    name: "500个"
                },
                {
                    label: "1000个",
                    name: "1000个"
                }
            ],
            cloudShow2:"1M",
            List2: [
                {
                    label: "1M",
                    name: "1M"
                },
                {
                    label: "2M",
                    name: "2M"
                },
                {
                    label: "4M",
                    name: "4M"
                },
                {
                    label: "6M",
                    name: "6M"
                },
                {
                    label: "8M",
                    name: "8M"
                },
                {
                    label: "10M",
                    name: "10M"
                },
                {
                    label: "12M",
                    name: "12M"
                },
                {
                    label: "20M",
                    name: "20M"
                },
                {
                    label: "50M",
                    name: "50M"
                }
            ],
            cloudShow3:"0.5年",
            List3: [
                {
                    label: "0.5年",
                    name: "0.5年"
                },
                {
                    label: "1年",
                    name: "1年"
                },
                {
                    label: "2年",
                    name: "2年"
                },
                {
                    label: "3年",
                    name: "3年"
                },
                {
                    label: "4年",
                    name: "4年"
                },
                {
                    label: "5年",
                    name: "5年"
                }
            ],
            money: 1,
            money1: 1,
            money2: 1,
            money3: 1,
            users:"",
            orderNumber:""
        };
    },
    computed: {

    },
    watch: {
        cloudShow: {
            handler(newVal, oldVal) {
                this.cloudShow = newVal;
            },
            deep: true
        },
    },
    created() {
      this.users = JSON.parse(window.localStorage.getItem("userInfo"));
    },
    mounted() { },
    methods: {
        handleChangelist(val) {
            if (val == "10G") {
                this.money = 1;
            } else if (val == "20G") {
                this.money = 2;
            } else if (val == "50G") {
                this.money = 3;
            } else if (val == "100G") {
                this.money = 4;
            } else if (val == "200G") {
                this.money = 5;
            } else if (val == "500G") {
                this.money = 6;
            } else if (val == "1000G") {
                this.money = 7;
            }
        },
        handleChangelist1(val) {
            if (val == "10个") {
                this.money1 = 1;
            } else if (val == "20个") {
                this.money1 = 2;
            } else if (val == "50个") {
                this.money1 = 3;
            } else if (val == "100个") {
                this.money1 = 4;
            } else if (val == "200个") {
                this.money1 = 5;
            } else if (val == "500个") {
                this.money1 = 6;
            } else if (val == "1000个") {
                this.money1 = 7;
            }
        },
        handleChangelist2(val) {
            if (val == "1M") {
                this.money2 = 1;
            } else if (val == "2M") {
                this.money2 = 2;
            } else if (val == "4M") {
                this.money2 = 3;
            } else if (val == "6M") {
                this.money2 = 4;
            } else if (val == "8M") {
                this.money2 = 5;
            } else if (val == "10M") {
                this.money2 = 6;
            } else if (val == "12M") {
                this.money2 = 7;
            } else if (val == "20M") {
                this.money2 = 8;
            } else if (val == "50M") {
                this.money2 = 9;
            }
        },
        handleChangelist3(val) {
            if (val == "0.5年") {
                this.money3 = 1;
            } else if (val == "1年") {
                this.money3 = 2;
            } else if (val == "2年") {
                this.money3 = 3;
            } else if (val == "3年") {
                this.money3 = 4;
            } else if (val == "4年") {
                this.money3 = 5;
            } else if (val == "5年") {
                this.money3 = 6;
            }
        },
        payBtn() {
            var postData = {
                productName: this.cloudtitleupgrade,
                describe:this.cloudShow,
                price:this.money,
                userId:this.users.uId
            }
            this.$http.post('/orderController/addOrder',qs.stringify(postData))
             .then((res) => {
                if(res.status == 200){
                   this.$message({
                       type:"success",
                       message:"添加订单成功"
                   });
                   this.orderNumber = res.data.orderNumber
                   this.$router.push({
                    name: "Raporderdetail",
                    params: {
                        cloudtitleupgrade: this.cloudtitleupgrade,
                        cloudShow: this.cloudShow,
                        money: this.money,
                        orderNumber: this.orderNumber,
                    }
                  });
                }
              }).catch((err) => {
                console.log(err);
           });
        },
        payBtn1() {
            //deviceCountupgrade: "设备数量升级",
            //bandwidthUpgrade: "带宽升级",
            //lifetimeupgrade: "使用年限升级",
            var postData = {
                productName: this.deviceCountupgrade,
                describe:this.cloudShow1,
                price:this.money1,
                userId:this.users.uId
            }
            this.$http.post('/orderController/addOrder',qs.stringify(postData))
             .then((res) => {
                if(res.status == 200){
                   this.$message({
                       type:"success",
                       message:"添加订单成功"
                   });
                   this.orderNumber = res.data.orderNumber
                   this.$router.push({
                    name: "Raporderdetail",
                    params: {
                        cloudtitleupgrade: this.deviceCountupgrade,
                        cloudShow: this.cloudShow1,
                        money: this.money1,
                        orderNumber: this.orderNumber
                    }
                });
                }
              }).catch((err) => {
                console.log(err);
           });
        },
        payBtn2() {
            var postData = {
                productName: this.bandwidthUpgrade,
                describe:this.cloudShow2,
                price:this.money2,
                userId:this.users.uId
            }
            this.$http.post('/orderController/addOrder',qs.stringify(postData))
            .then((res) => {
               if(res.status == 200){
                  this.$message({
                      type:"success",
                      message:"添加订单成功"
                  });
                  this.orderNumber = res.data.orderNumber
                  this.$router.push({
                   name: "Raporderdetail",
                   params: {
                    cloudtitleupgrade: this.bandwidthUpgrade,
                    cloudShow: this.cloudShow2,
                    money: this.money2,
                    orderNumber: this.orderNumber
                   }
                });
               }
             }).catch((err) => {
               console.log(err);
           });
        },
        payBtn3() {
            var postData = {
                productName: this.lifetimeupgrade,
                describe:this.cloudShow3,
                price:this.money3,
                userId:this.users.uId
            }
            this.$http.post('/orderController/addOrder',qs.stringify(postData))
            .then((res) => {
               if(res.status == 200){
                  this.$message({
                      type:"success",
                      message:"添加订单成功"
                  });
                  this.orderNumber = res.data.orderNumber
                  this.$router.push({
                   name: "Raporderdetail",
                   params: {
                    cloudtitleupgrade: this.lifetimeupgrade,
                    cloudShow: this.cloudShow3,
                    money: this.money3,
                    orderNumber: this.orderNumber
                   }
                });
               }
             }).catch((err) => {
               console.log(err);
           });
        }
    }
};